<!DOCTYPE html>
<html id="iframe">
<head>
    <meta charset="utf-8"/>

    <title>{:C('sitename')}55555</title>

    <meta name="renderer" content="webkit">
    <meta name="format-detection" content="telephone=no,email=no"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta name="telephone=no" content="format-detection">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no"/>

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/lib.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/page.css"/>
    <link rel="stylesheet" href="__PUBLIC__/tables/tables.css">
</head>
<style>
    html{
        overflow-y: scroll !important;
        height: 35rem;
    }
    body {
        height: 35rem !important;
        overflow-y: scroll;
        margin: 0;
    }

    .button {
        display: inline-block;
        width: 3rem;
        height: 0.8rem;
        line-height: 0.8rem;
        font-size: 0.9rem;
        background: -webkit-linear-gradient(#818078, #292928);
        background: -o-linear-gradient(#818078, #292928);
        background: -moz-linear-gradient(#818078, #292928);
        background: linear-gradient(#818078, #292928);
    }

    .leftRight .nav, .leftRight .content {
        padding: 0 !important;
    }

    .content p {
        display: inline-block;
    }

    .keyborad {
        display: none;
        position: absolute;
        top: 33px;
        left: 0px;
        z-index: 10;
        padding: 3px;
        margin: 0 !important;
        border-radius: 6px;
        background-color: #6a6e71;
        width: 100%;
    }

    .keyborad p {
        width: 100%;
        margin: 5px 0;
        text-align: center;
    }

    .keyborad p span {
        display: inline-block;
        width: 13%;
        height: 40px;
        line-height: 40px;
        background-color: #293039;
        color: #FFF;
        text-align: center;
        border-radius: 3px;
    }

    .keyborad strong {
        display: inline-block;
        width: 15%;
        border-radius: 3px;
        height: 40px;
        line-height: 40px;
        color: #FFF;
    }

    .keyborad .qc, .keyborad .jt, .keyborad .fs, .keyborad .close {
        border: 1px solid #ffe668;
        background-color: #262626;
    }

    .keyborad strong {
        display: inline-block;
        width: 23.5%;
        border-radius: 3px;
        height: 40px;
        line-height: 40px;
        color: #ffe668;
    }
    .input-chatting{
        width: 100%;
        padding: 15px 12px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        left: 0;
        top: 0;
        z-index: 9999999;
        background: #f7f7f7;
    }
    .input-chattings{
        width: 100%;
        padding: 15px 12px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        left: 0;
        bottom: 0;
        z-index: 9999999;
        background: #f7f7f7;
    }
    .input-chatting >img{
        width: 24px;
    }
    .input-chatting input{
        flex: 1;
        height: 36px;
        border-radius: 4px;
        margin: 0 8px;
        padding: 0 9px;
        box-sizing: border-box;
    }
    .input-chatting button{
        color: #fff;
        background-color: #08c261;
        border-radius: 3px;
        border: none;
        outline: none;
        height: 28px;
        padding: 2px 18px;
        box-sizing: content-box;
    }
    .input-chattings >img{
        width: 24px;
    }
    .input-chattings input{
        flex: 1;
        height: 36px;
        border-radius: 4px;
        margin: 0 8px;
        padding: 0 9px;
        box-sizing: border-box;
    }
    .input-chattings button{
        color: #fff;
        background-color: #08c261;
        border-radius: 3px;
        border: none;
        outline: none;
        height: 28px;
        padding: 2px 18px;
        box-sizing: content-box;
    }
    .menu-ul-t{
        width: 90px;
        position: fixed;
        display: none;
        top: 56px;
        right: 12px;
        padding: 8px;
        background: #3a3737;
        opacity: 0.98;
        border-radius: 5px;
        z-index: 9999999999;
    }
    .menu-ul{
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .menu-ul dd{
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: center;
        padding: 4px 0;
    }
    .menu-ul dd>a{
        width: 100%;
        display: flex;
        align-items: center;
        box-sizing: border-box;
    }
    .menu-ul a > img{
        width: 15px;
        box-sizing: content-box;
        padding-right: 10px;
    }
    .menu-ul a p{
        flex: 1;
        padding: 0 0 6px 0.6rem;
        box-sizing: border-box;
        color: #fff;
        font-size: 13px;
        letter-spacing: 5px;
        border-bottom: 1px solid #e7e7e7;
    }
</style>
<body>


<!--弹窗-北京赛车-->
<link rel="stylesheet" type="text/css" href="/Template/Home/Run/css/zhicwl-z.css"/>

<style>
    .zhicwl-qiejlf-tab-04 .zhicwl-akodr dl dt {
        width: 33%;
        margin-bottom: 6px;
    }

    .zhicwl-qiejlf-tab-05 .zhicwl-akodr dl dt {
        width: 100%;
    }

    .zhicwl-qiejlf-tab-05 .zhicwl-akodr dl dt:nth-of-type(10) {
        width: 100%;
    }

    .zhicwl-qiejlf-tab-05 .zhicwl-akodr dl dt span {
        font-weight: normal;
    }

    .zhicwl-qiejlf-tab-06 .zhicwl-akodr dl dt {
        width: 20%;
    }
    .footer-info {
        width: 100%;
        height: 100vh;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: rgba(0, 0, 0, 0.16);
        z-index: 999999999999999999;
        display: none;
        font-size: 0.346rem;
        color: #000;
    }
    .fotter-box{
        width: 64%;
        display: flex;
        flex-flow: column nowrap;
        justify-content: center;
        padding: 24px 12px;
        background: #fff;
        border-radius: 6px;
        transform: translateY(-50%);
        margin: 50vh auto;
    }
    .header-box{
        display: flex;
        align-items: center;
        padding-bottom: 24px;
    }
    .header-box >h3{
        font-size: 15px;
        flex: 1;
        text-align: center;
    }
    .header-box img{
        width: 18px;
    }
    .fotter-box p{
        padding: 8px 0;
        text-align: center;
        font-size: 13px;
    }
    .white_content, .white_content1, .white_content2, .white_content3, .white_content4 {
        position: absolute;
        bottom: 0;
        width: 100vw;
        height: 60vh;
        bottom: -100vh;
        left: 0;
        background-color: #fff;
        z-index: -1002111111;
        overflow: auto;
        border-radius: 6px 6px 0 0;
        opacity: 0;

    }
    .active-white{
        position: fixed;
        width: 100vw;
        height: 60vh;
        bottom: 0;
        left: 0;
        z-index: 1002111111;
        opacity: 1;
        transition: all 0.72s ease-in-out;
    }

    .close, .close1, .close2, .close3, .close4 {
        display: none;
        width: 0.88rem;
        height: 2.09rem;
        position: fixed;
        left: 50%;
        bottom: 59.3%;
        z-index: 111111111111;
        transform: translate(-0.44rem);
    }

    #light > p, #light1 > p, #light2 > p, #light3 > p, #light4 > p {
        width: 10rem;
        margin: 0;
        height: 1.06rem;
        position: fixed;
        background-color: #262626;
        bottom: calc(60% - 1.06rem);
        z-index: 10021111111;
        border-bottom: 1px solid #67603a;
        text-align: center;
        line-height: 1.06rem;
        font-size: 0.546rem;
        color: #ffe668;
    }
    .header-light{
        display: flex;
        align-items: center;
        color: #333;
        padding: 8px 16px;
    }
    .header-light p{
        flex: 1;
        font-size: 14px;
        text-align: center;
    }
    .header-light img{
        width: 18px;
    }
    .tb-continer .title {
        height: 1rem;
        line-height: 1rem;
        text-align: center;
        background: #333;
        color: #fff;
    }
</style>
<body>
<div class="zhicwl-csplr" style="padding-bottom:25px;position: fixed;top: 0;z-index: 1111111;padding-top: 18px">

    <div class="zhicwl-yrlof" style="margin:0 auto; display: none;">
        <div class="zhicwl-arwort">
            <div class="zhicwl-arwort-div">
                <dl class="zhicwl-tc-01 display-box box-align-center">
                    <dt class="on"><span>猜庄闲</span></dt>
                </dl>
            </div>
        </div>
    </div>


    <section class="zhicwl-qiejlf">
        <!--猜庄闲-->
        <div class="zhicwl-qiejlf-tab zhicwl-qiejlf-tab-04">
            <div class="zhicwl-ldprta display-box box-align-center" style="margin-top:0;">
                <h2 class="zhicwl-ldprta-left box-flex" style="padding-top:0.9rem;">猜龙虎和</h2>
                <div class="zhicwl-repavb zhicwl-guanb">
                    <img src="__PUBLIC__/Home/img/backIcon.png" alt="" style="position: relative;top:0.7rem;">
                </div>
            </div>

            <div class="zhicwl-keapr">
                <div class="zhicwl-akodr">
                    <dl>
                        <dt>
                            <div>
                                <span data="龙">Dragon</span>
                                <samp>x {:C('longhu_z_point')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span data="和">tie</span>
                                <samp>x {:C('longhu_h_point')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span data="虎">TigerFight</span>
                                <samp>x {:C('longhu_x_point')}</samp>
                            </div>
                        </dt>

                    </dl>
                </div>
            </div>
        </div>
        <!--/猜庄闲-->

    </section>

</div>
<!--/弹窗-北京赛车-->

<div id="input-chatting">
    <img class="zhicwl-xiaz" src="__PUBLIC__/Home/img/binding.png" alt="">
    <input type="text" name="" id="textarea">
    <button id="postDataOk">send</button>
    <button id="selectMenu" style="background: #7181e8;margin-left: 9px;">more</button>
</div>
<div id="menu-ul-t" class="menu-ul-t">
    <dl class="menu-ul">
        <!-- <dd>
            <a href="/Home/Run/index">
                <img src="__PUBLIC__/Home/img/menuList1.png" alt="">
                <p>大厅</p>
            </a>
        </dd>
        <dd>
            <a href="{:U('Home/Fen/addpage')}?type=pk10">
                <img src="__PUBLIC__/Home/img/menuList2.png" alt="">
                <p>充值</p>
            </a>
        </dd>
        <dd>
            <a href="{:U('Home/Fen/xiapage')}?type=pk10">
                <img src="__PUBLIC__/Home/img/menuList3.png" alt="">
                <p>提现</p>
            </a>
        </dd> -->
        <dd>
            <a href="javascript:void(0)" onclick="openRecord()">
                <img src="__PUBLIC__/Home/img/menuList3.png" alt="">
                <p>Note</p>
            </a>
        </dd>
        <dd>
            <a href="javascript:void(0)"onclick="openKjssc()">
                <img src="__PUBLIC__/Home/img/menuList4.png" alt="">
                <p>record</p>
            </a>
        </dd>
        <dd>
            <a href="javascript:void(0)" onclick="openRule()">
                <img src="__PUBLIC__/Home/img/menuList2.png" alt="">
                <p>rule</p>
            </a>
        </dd>
        <!-- <dd>
            <a href="/Home/User/index">
                <img src="__PUBLIC__/Home/img/menuList4.png" alt="">
                <p>我的</p>
            </a>
        </dd> -->
        <dd>
            <a href="javascript:void(0)" id="lastmenu">
                <img src="__PUBLIC__/Home/img/menuList4.png" alt="">
                <p>Balance</p>
            </a>
        </dd>
    </dl>
</div>
<div id="light1" class="white_content1">
    <div class="header-light">
        <p>Notes</p>
        <img src="__PUBLIC__/Home/img/backIcon.png" onclick="closeRecord()" alt="">
    </div>
    <table class="tb-continer" style="margin-top:0.28rem;">
        <thead>
        <tr class="title">
            <th>income:  <span id="jin">0</span></th>
            <th>OutItem:  <span id="chu">0</span></th>
            <th>lose/win:  <span id="ying">0</span></th>
        </tr>
        </thead>
    </table>
    <table class="tb-continer">
        <thead>
        <tr class="title">
            <th>Bet options</th>
            <th>Bet amount</th>
            <th>periods</th>
            <th>result</th>
        </tr>
        </thead>
        <tbody id="danzhuList">

        </tbody>
    </table>
</div>

<div id="light2" class="white_content2">
    <div class="header-light">
        <p>Lottery record</p>
        <img src="__PUBLIC__/Home/img/backIcon.png" onclick="closeKjssc()" alt="">
    </div>
    <div class="kjssc_wrapper" style="margin-top:0.28rem;">
        <div class="tab-content">
            <div id="app1"></div>
        </div>
    </div>
</div>

<div id="light3" class="white_content3">
    <div class="header-light">
        <p>Rules of the game</p>
        <img src="__PUBLIC__/Home/img/backIcon.png" onclick="closeRule()" alt="">
    </div>
    <div class="sscrule" style="color:#333;padding:0 0.3rem; margin-top:0.28rem;">
        <br>
        <div class="">
            <h4 class="cl-orange" style="font-size:0.4rem; color:#333;">【game introduction】</h4><br>
            <p>Dragon and tiger fight, that is to determine the size of the card to win or lose the game. The order of flower color from big to small is: Safflower slice, spade K is the biggest brand, square piece a is the smallest, and the same number of points and the same color are the same。<br/>
        </div>
        <br>
        <div class="">
            <h4 class="cl-orange" style="font-size:0.4rem; color:#333;">【Basic play】</h4><br>
            <p>
                Players can bet on dragon, tiger, and three gates.

                Dutch officials only sent two cards, namely dragon and tiger. Each school each sends a card, the two sides fight big.

                1. Eight pairs of playing cards are widely used as the benchmark.

                2. The cards are put into the boots after being washed. Players can guess the dragon, tiger, and three items during the game.

                3. The dragon and the tiger each hand out a card.
            </p>
        </div>
        <br>
        <div class="">
            <h4 class="cl-orange" style="font-size:0.4rem; color:#333;">【definition】</h4><br>
            Dragon and tiger fight is one of the most civilized and fair entertainment items in the world. Whoever has the biggest card wins。
            <br>
            <br>
            <h5 class="cl-blue" style="font-size:0.4rem; color:#333;">
                【Licensing and licensing】

            </h5><br>
            <p>The first card of the Dragon sect and the second card of the tiger faction do not need to be replaced。<br>
            </p>

        </div>
        <br>
        <h5 class="cl-blue" style="font-size:0.4rem; color:#333;">
            【Game odds】
        </h5>
        <br>
        <p>
            ■odds：<br />
            <small>
                Dragon，Including the original{:C('longhu_z_point')}times<br />
                Tiger，Including the original{:C('longhu_x_point')}times<br />
                Tie，Including the original{:C('longhu_h_point')}times<br />
            </small>
            ■Dragon Quotal：{:C('longhu_z_money')}<br />
            ■Tiger Quota：{:C('longhu_x_money')}<br />
            ■Tie Quotal：{:C('longhu_h_money')}<br/>
        </p>


        <br>

        <!--<br> <h4 class="cl-orange" style="font-size:0.4rem; color:#fff98d;">每期下注：总额{:C('hundred_max_money')}封顶</h4><br>-->
        <h4 class="cl-orange" style="font-size:0.4rem; color:#333;">【explain】</h4><br>
        <p>
            <!-- ■没带名次默认投第一名，如「双/100」第一名双$100、「123/100」第一名123号各$100<br /> -->
            ■There may be a delay of 1-2 seconds due to the uncertain network quality in different places. The system will determine whether the bet is successful or not。<br />

        </p>
    </div>
</div>
</div><div class="footer-info" id="footer-info">
    <div class="fotter-box">
        <div class="header-box">
            <h3>Account Balance</h3>
            <img src="__PUBLIC__/Home/img/backIcon.png" id="clouse-footer" alt="">
        </div>
        <p>Balance：<span class="money">{$userinfo.points}</span></p>
        <p>Account：<span class="Name">{$userinfo.nickname}</span></p>
    </div>
</div>
<div class="main-box">
    <!--第一行（表单、积分在线人数）-->
    <div class="top" style="width:100%;position: fixed;top:0;z-index:9999;">
        <div class="keyborad">
            <p>
                <span>1</span>
                <span>2</span>
                <span>3</span>
                <span>4</span>
                <span>5</span>
                <span>/</span>
            </p>
            <p>
                <span>6</span>
                <span>7</span>
                <span>8</span>
                <span>9</span>
                <span>0</span>
            </p>
            <p>
                <span>庄</span>
                <span>闲</span>
                <span>和</span>
                <span>庄对</span>
                <span>闲对</span>
            </p>
            <p>
                <strong class="qc">清除</strong>
                <strong class="jt">←</strong>
                <strong class="fs">发送</strong>
                <strong class="close">关闭</strong>
            </p>
        </div>

        <!-- <div class="info">
            <p>点数：<span id="sy">{$userinfo.points}</span>点</p>
            <p>人数：<span id="xs"></span>人</p>
        </div> -->

        <!-- <p>
            <span>庄</span>
            <span>闲</span>
            <span>和</span>
            <span>庄对</span>
            <span>闲对</span>
        </p>
        <p>
            <strong class="qc">清除</strong>
            <strong class="jt">←</strong>
            <strong class="fs">发送</strong>
            <strong class="close">关闭</strong>
        </p> -->
    </div>
</div>
<div id="load" style="text-align: center;font-size: 14px;color:#fff;">loading...</div>
<div class="chatting" style="display: none;margin-bottom:25rem !important;padding-top: 4.8rem;overflow-y: scroll;">
    <volist name="list" id="vo">

        <if condition="$vo['type'] eq 'admin'">
            <div class="chatting-li qtr orange">
            <!--class="chatting-li qtr orange"-->
                <div class="portrait"><img src="{$vo.head_img_url}"/></div>
                <div class="content">
                    <small><span class="name">{$vo.from_client_name}</span>
                        <time>{$vo.time}</time>
                    </small>
                    <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
                </div>
            </div>
        </if>
        <if condition="$vo['type'] eq 'system'">
            <div class="chatting-li qtr pink">
                <div class="portrait"><img src="{$vo.head_img_url}"/></div>
                <div class="content">
                    <small><span class="name">{$vo.from_client_name}</span>
                        <time>{$vo.time}</time>
                    </small>
                    <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
                </div>
            </div>
        </if>
        <if condition="$vo['type'] eq 'say'">
            <div class="chatting-li">
                <div class="portrait"><img src="{$vo.head_img_url}"/></div>
                <div class="content">
                    <small><span class="name">{$vo.from_client_name}</span>
                        <time>{$vo.time}</time>
                    </small>
                    <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
                </div>
            </div>
        </if>
        <if condition="$vo['type'] eq 'error' && $userinfo['id'] eq $vo['uid']">
            <div class="chatting-li qtr green">
                <div class="portrait"><img src="{$vo.head_img_url}"/></div>
                <div class="content">
                    <small><span class="name">{$vo.from_client_name}</span>
                        <time>{$vo.time}</time>
                    </small>
                    <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
                </div>
            </div>
        </if>
        <if condition="$vo['type'] eq 'say_error' && $userinfo['id'] eq $vo['uid']">
            <div class="chatting-li">
                <div class="portrait"><img src="{$vo.head_img_url}"/></div>
                <div class="content">
                    <small><span class="name">{$vo.from_client_name}</span>
                        <time>{$vo.time}</time>
                    </small>
                    <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
                </div>
            </div>
        </if>
</volist>
</div>

<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<!--聊天-->
<script type="text/javascript" src="__PUBLIC__/worker/js/swfobject.js"></script>
<script type="text/javascript" src="__PUBLIC__/worker/js/web_socket.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<script src="__PUBLIC__/tables/tables.js"></script>
<script type="text/javascript">
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        //在微信中打开需要的操作
        $('#input-chatting').removeClass('input-chatting').addClass('input-chattings')
    } else {
    //不在微信中打开
    console.log('不在微信中打开')
       $('#input-chatting').removeClass('input-chattings').addClass('input-chatting')
    }
    function openRecord() {
        //获取数据
        $.post('/Home/Run/hundredRecord',{
            game:'longhu',
            page:0
        },function(e){
            var con=eval('('+e+')').content;
            var con_zhongji=eval('('+e+')').zongji;
            var str='';
            con.forEach((it)=>{
                if(it.type.indexOf('/')!=-1){
                    var sp=it.type.split('/');
                    var spa=it.points.split('/');
                    for(let i=0;i<sp.length;i++){
                        str+=` <tr class="${it.odds_points>0?'yin':'shu'}"><td>${sp[i]}</td><td>${spa[i]}</td><td>${it.number}</td><td>${it.is_add==="0"?'未结算':it.odds_points>0?'赢':it.odds_points<0?'输':'退回'}</td></tr>`
                    }
                }else{
                    str+=`<tr class="${it.odds_points>0?'yin':'shu'}">
                            <td>${it.type}</td>
                            <td>${it.points}</td>
                            <td>${it.number}</td>
                            <td>${it.is_add==="0"?'未结算':it.odds_points>0?it.odds_points:it.odds_points<0?it.odds_points:'退回'}</td>
                           </tr>`
                }
            });
            document.querySelector('#danzhuList').innerHTML=str;
            document.querySelector('#jin').innerHTML=eval('('+e+')')['zongji']['jin'];
            document.querySelector('#chu').innerHTML=eval('('+e+')')['zongji']['chu'];
            document.querySelector('#ying').innerHTML=eval('('+e+')')['zongji']['ying'];
            document.getElementById('light1').classList.add('active-white');
            document.getElementById('fade1').style.display = 'block';
        });
    }

    function closeRecord() {
        document.getElementById('light1').classList.remove('active-white');
        // document.getElementById('light1').style.display = 'none';
        document.getElementById('fade1').style.display = 'none';
    }

    function openKjssc() {
        $.post('/Home/Run/kjlonghu',[],function(e){
            var tb=new Tables('#app1',6);
            var list=eval('('+e+')').content;
            for(let i=0;i<list.length;i++){
                let it=list[i];
                let h=Math.floor(i%6+1);
                let l=Math.floor(i/6+1);
                let as=it.award_numbers.split(',');
                as.forEach((at)=>{
                    switch(at){
                        case '龙':
                            tb.addL(h,l);
                            break;
                        case '虎':
                            tb.addHu(h,l);
                            break;
                        case '和':
                            tb.addH(h,l);
                            break;

                    }
                })
            }

            document.getElementById('light2').classList.add('active-white');
            document.getElementById('fade2').style.display = 'block';
        });
    }

    function closeKjssc() {
        document.getElementById('light2').classList.remove('active-white');
        document.getElementById('fade2').style.display = 'none';
    }

    function openRule() {
        document.getElementById('light3').classList.add('active-white');
        document.getElementById('fade3').style.display = 'block';
    }

    function closeRule() {
        document.getElementById('light3').classList.remove('active-white');
        document.getElementById('fade3').style.display = 'none';
    }
    $('#lastmenu').click(function(){
        $('#footer-info').toggle()
    })
    $('#clouse-footer').click(function(){
        $('#footer-info').hide()
    })
    $("#selectMenu").click(function(){
        $("#menu-ul-t").slideToggle()
        return false
    })
    $(document).click(function(){
        $("#menu-ul-t").hide()
    })
    setTimeout(function () {
        $('#load').css('display', 'none');
        $('.chatting').css('display', 'block');
    }, 1500);
    $('.jp_btn').click(function () {
        if ($('.keyborad').is(":hidden")) {
            $('.keyborad').show();
        } else {
            $('.keyborad').hide();
        }

    })

    $('.keyborad span').click(function () {
        var value = $(this).text();
        var input_value = $('#textarea').val();
        $('#textarea').val(input_value + value);
    })

    $('.keyborad .qc').click(function () {
        $('#textarea').val('');
    })

    $('.keyborad .jt').click(function () {
        var input_value = $('#textarea').val();
        var str = input_value.substr(0, input_value.length - 1);
        $('#textarea').val(str);
    })

    $('.keyborad .fs').click(function () {
        $('.submit_btn').click();
        $('.keyborad').hide();
    })

    $('.keyborad .close').click(function () {
        $('.keyborad').hide();
    })

    $('.submit_btn').click(function () {
        $('.keyborad').hide();
    })
    // $('#textarea').blur(function(){
    // 	$('.keyborad').hide();
    // })


    document.onkeydown = function (event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            onSubmit();
            return false;
        }
    }
    $('#postDataOk').click(onSubmit);
    if (typeof console == "undefined") {
        this.console = {
            log: function (msg) {
            }
        };
    }
    WEB_SOCKET_SWF_LOCATION = "__PUBLIC__/worker/swf/WebSocketMain.swf";
    WEB_SOCKET_DEBUG = true;
    var ws, name;

    // 连接服务端
    function connect() {
        // 创建websocket
        ws = new WebSocket("ws://" + document.domain + ":15101");
        // 当socket连接打开时，发送登录信息
        ws.onopen = function () {
            // login_data = '{"type":"pong"}';
            var name = "{$userinfo.nickname}";
            // 登录
            var userid = "{$userinfo.id}";
            var login_data = '{"type":"login","client_name":"' + name.replace(/"/g, '\\"') + '","client_id":"' + userid + '"}';
            console.log("websocket握手成功，发送登录数据:" + login_data);
            ws.send(login_data);
        };
        // 当有消息时根据消息类型显示不同信息
        ws.onmessage = onmessage;
        ws.onclose = function () {
            console.log("连接关闭，定时重连");
            connect();
        };
        ws.onerror = function () {
            console.log("出现错误");
        };
    }
    $(connect);
    var inte = parseInt(Math.random() * 12 + 1);
    function  magArr(content) {
        var strArr=[];
        try {
            var arr=eval(content);
            for(let key in arr){
                strArr.push(key+'/'+arr[key]);
            }
        }catch(e){
            strArr.push(content);
        }
        return strArr;
    }
    function maginfo(content) {
        try{
            var cont=eval("("+content+")");
        }catch (e){
            return content;
        }
        let show='';
        for(let key in cont){
            show+=key+"/"+cont[key]+" "
        }
        return show;
    }
    var money_kou=0;
    function onmessage(e) {
        var rate = 0;
        var robot_rate = e['robot_rate'] ? e['robot_rate'] : 3;
        switch (e['robot_rate']) {
            case 5:
                rate = 5;
                break;
            case 4:
                rate = 10;
                break;
            case 3:
                rate = 25;
                break;
            case 2:
                rate = 35;
                break;
            case 1:
                rate = 45;
                break;
            default:
                rate = 25;
                break;
        }
        var data = eval("(" + e.data + ")");
        // console.log(data);
        switch (data['type']) {
            // 服务端ping客户端
            case 'ping':
                $('#xs').html(data.content + {C: ('online')});
                ws.send('{"type":"pong"}');
                inte--;
                if (inte == 0) {
                    ws.send('{"type":"robot"}');
                    console.log(e.data);
                    inte = parseInt(Math.random() * rate + 1) + 2;
                }
                break;
            // 登录 更新用户列表
            case 'login':
                console.log(data['client_name'] + "登录成功");
                break;
            // 发言
            case 'say':
                say(data['uid'], data['from_client_name'], data['head_img_url'], data['content'], data['time']);
                break;
            // 用户退出 更新用户列表
            case 'logout':
                break;
            case 'broadcast':
            //alert('client');

            //房管
                case 'admin':
                var strArr=magArr(data["content"]);
                function show(){
                    if ('{$userinfo.id}' == data['uid']) {
                        strArr.forEach((it)=> {
                            $(".chatting").prepend('<div class="chatting-li qtr orange"><div class="portrait"><img src="' + data['head_img_url'] + '"/></div><div class="content"><small><span class="name">' + data["from_client_name"] + '</span><time>' + data["time"] + '</time></small><p>' + it+ '</p></div></div>');
                        });
                    } else {
                        strArr.forEach((it)=> {
                            $(".chatting").prepend('<div class="chatting-li qtr orange"><div class="portrait"><img src="' + data['head_img_url'] + '"/></div><div class="content"><small><span class="name">' + data["from_client_name"] + '</span><time>' + data["time"] + '</time></small><p>' + it + '</p></div></div>');
                        });
                    }
                }
                if(data['content'].indexOf('竞猜成功')!==-1){
                    $('.money',window.top.document).html(Number($('.money',window.top.document).html()) - money_kou);
                    money_kou=0;
                }else if(data['code']+''===''+400){
                    setTimeout(show,200);
                    break;
                }
                show();
                break;
            //系统
            case 'system':
                var strArr=magArr(data["content"]);
                if ('{$userinfo.id}' == data['uid']) {
                    strArr.forEach((it)=> {
                        $(".chatting").prepend('<div class="chatting-li qtr green"><div class="portrait"><img src="' + data['head_img_url'] + '"/></div><div class="content"><small><span class="name">' + data["from_client_name"] + '</span><time>' + data["time"] + '</time></small><p>' +it + '</p></div></div>');
                    });
                } else {
                    strArr.forEach((it)=> {
                        $(".chatting").prepend('<div class="chatting-li qtr orange"><div class="portrait"><img src="' + data['head_img_url'] + '"/></div><div class="content"><small><span class="name">' + data["from_client_name"] + '</span><time>' + data["time"] + '</time></small><p>' +it+ '</p></div></div>');
                    });
                }
                break;
            //积分减
            case 'points':
                $('#sy').html((parseFloat($('#sy').html()) - data['content']).toFixed(1));
                break;
            //积分加
            case 'pointsadd':
                $('.money',window.parent.document).html((parseFloat($('.money',window.parent.document).html()) + data['points']).toFixed(1));
                parent.layer.msg('恭喜竞猜成功');
                // alert('aaaa')
                break;
            //重载
            case 'reload':
                if ('{$userinfo.id}' == 9) {
                    window.location.href = window.location.href;
                }
                break;
            //切换
            case 'switch':
                parent.location.reload();
                break;
            case 'addpoints':
                $('.money').html(data['points']);
                break;
        }
    }
    var def_content='';
    function wsTz(tz, money) {
        var headimgurl = '{$userinfo.headimgurl}';
        var from_client_name = '{$userinfo.nickname}';
        def_content=tz.replace(/5555/g, money);
        def_content=eval('('+def_content+')');
        Object.keys(def_content).forEach((e)=>{
            ws.send('{"type":"say","client_name":"' + from_client_name + '","headimgurl":"' + headimgurl + '","content":{"'+e+'":'+def_content[e]+'}}');
        });

        $('#textarea').val('');
        $(".zhicwl-qiejlf .zhicwl-qiejlf-tab .zhicwl-keapr dt").removeClass('on');
        $(".zhicwl-fxalpr-an1").removeClass('on');
    }

    function checkData() {
        var tz = [];
        var hms = "";
        //获取数据
        var fq = window.parent;
        // let list = document.querySelectorAll('.zhicwl-qiejlf-tab .zhicwl-akodr dt.on');
        let list = $('.zhicwl-qiejlf-tab .zhicwl-akodr dt.on');

        if (list != null && list.length > 0) {
            //存在
            let moneyList = {};
            // list.forEach((it) => {
            //     moneyList[it.querySelector('span').innerText] = 5555;
            // });
            list.each(function () {
                moneyList[$(this).find('span').attr('data')] = 5555;
            })
            console.log(JSON.stringify(moneyList));
            return JSON.stringify(moneyList);
        } else {
            alert("请投注");
            return false;
        }
    }
    function GetPostData(oVal,ignoreCase=true){
        let gz={
            '龙':['L','龙'],
            '虎':['Hu','虎'],
            '和':['H','和'],

        };
        let type={
            '全撤':['全撤','CQ','Q'],
            '撤龙':['撤龙','CL'],
            '撤虎':['撤虎','CHu'],
            '撤和':['撤和','CH'],
            '梭哈龙':['SHL','梭哈龙'],
            '梭哈虎':['SHHu','梭哈虎'],
            '梭哈和':['SHH','梭哈和'],
        };
        let val=oVal;
        try{
            if(ignoreCase){
                val=val.toLocaleLowerCase();
                Object.keys(gz).forEach((key)=>{
                    let obj=gz[key];
                    obj.forEach((vl,key)=>{
                        obj[key]=vl.toLocaleLowerCase();
                    })
                });
                Object.keys(type).forEach((key)=>{
                    let obj=type[key];
                    obj.forEach((vl,key)=>{
                        obj[key]=vl.toLocaleLowerCase();
                    })
                });
            }
            //优先判断是否存在type
            let typeName=null;
            Object.keys(type).forEach((key)=>{
                let obj=type[key];
                if(!typeName && obj.includes(val)){
                    typeName=key;
                }
            });
            if(typeName){
                return typeName+'/1';
            }
            let name=val.match(/[a-zA-Z\u4e00-\u9fa5]+/i)[0];
            let money=val.match(/\d+/)[0];
            let overName=null;
            Object.keys(gz).forEach((key)=>{
                let obj=gz[key];
                console.log(obj);
                if(!overName && obj.includes(name)){
                    overName=key;
                }
            });
            return overName?overName+'/'+money:oVal;
        }catch (e) {
            return oVal;
        }
    }
    // 提交对话
    function onSubmit() {
        alert('Temporary does not support(暂不支持)');
        var headimgurl = '{$userinfo.headimgurl}';
        var input = document.getElementById("textarea");
        var input_value = GetPostData(input.value);
        console.log(input_value)
        var from_client_name = '{$userinfo.nickname}';
        if (input.value == '') {
            $('#textarea').focus();
            return false;
        }

        // ws.send('{"type":"say","client_name":"' + from_client_name + '","headimgurl":"' + headimgurl + '","content":{"闲": 600,"庄": 300}}');
        let list = input_value.split('/');
        ws.send('{"type":"say","client_name":"' + from_client_name + '","headimgurl":"' + headimgurl + '","content":{"' + list[0] + '":' + list[1] + '}}');
        $('#textarea').val('');
        //$('#dialog').scrollTop(0);
    }
    // 发言
    function say(uid, from_client_name, head_img_url, content, time) {
        if(!content){
            content=def_content;
        }
        var strArr=magArr(content);
        if ('{$userinfo.id}' == uid) {
            var arr=content;
            console.log(arr);
            strArr.forEach((it)=>{
                $(".chatting").prepend('<div class="chatting-li"><div class="portrait"><img src="'+ head_img_url +'"/></div><div class="content"><small><span class="name">' + from_client_name + '</span><time>' + time +' </time></small><p>'+it+'</p></div></div>');

            })
        } else {
            strArr.forEach((it)=>{
                $(".chatting").prepend('<div class="chatting-li"><div class="portrait"><img src="' + head_img_url + '"/></div><div class="content"><small><span class="name">' + from_client_name + '</span><time>' + time + '</time></small><p>' + it + '</p></div></div>');
            })
        }
    }
</script>
<!--聊天-->

<!--推送-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js"></script>
<script>
    var uid = '{$userinfo.id}';
</script>
<script>
    function escape2Html(str) {
        var arrEntities = {'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"'};
        return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
            return arrEntities[t];
        });
    }

    $(document).ready(function () {
        // 连接服务端
        var socket = io('http://' + document.domain + ':12223');
        // 连接后登录
        socket.on('connect', function () {
            socket.emit('login', uid);
        });
        var fpTime=null;
        var sptime=10;
        var tasm=null;
        // 后端推送来消息时
        socket.on('new_msg', function (msg) {
            var data = eval("(" + escape2Html(msg) + ")");
            if (data['type'] == '3' || data['type'] == '4' || data['type'] == '1' || data['type'] == '2') {
                return false;
            }
            if(data["clear"] && data["clear"]==="1"){
                if(data['to']){
                    if(data["to"] == '{$userinfo.id}'){
                        $('.money',window.parent.document).html(($('.money',window.parent.document).html()*1)+data["content"]*1);
                    }
                }else{
                    $('.money',window.parent.document).html(($('.money',window.parent.document).html()*1)+data["content"]*1);
                }
                return;
            }
            var time = data['time'];
            var content = data['content'];
            if (data['points'] && data['to'] == '{$userinfo.id}') {
                var points = parseFloat($('#sy').html()) + parseFloat(data['points']);
                $('#sy').html(points);
            }

            $(".chatting").prepend('<div class="chatting-li qtr pink"><div class="portrait"><img src="/Public/main/img/system.jpg"/></div><div class="content"><small><span class="name">客服</span><time>' + time + '</time></small><p>' + content + '</p></div></div>');
            if(data.content.indexOf('已封盘')!=-1){
                return;
            }
            if(data.content.indexOf('距离封盘')!=-1){
                sptime=10;
                $('#zy_loead_top',window.parent.document).show()
                clearInterval(fpTime);
                fpTime=setInterval(()=>{
                    sptime--;
                    if(sptime<=0){
                        $('#zy_loead_top',window.parent.document).hide();
                        clearInterval(fpTime);
                        return;
                    }
                    $('#zy_loead_top',window.parent.document).html(sptime)
                },1000)
            }
        });
        socket.on('new_msg26_1', function (msg) {
            var data = eval("(" + escape2Html(msg) + ")");
            if (data['type'] == '3' || data['type'] == '4' || data['type'] == '1' || data['type'] == '2') {
                return false;
            }
            if(data["clear"] && data["clear"]==="1"){
                if(data['to']){
                    if(data["to"] == '{$userinfo.id}'){
                        $('.money',window.parent.document).html(($('.money',window.parent.document).html()*1)+data["content"]*1);
                    }
                }else{
                    $('.money',window.parent.document).html(($('.money',window.parent.document).html()*1)+data["content"]*1);
                }
                return;
            }
            var time = data['time'];
            var content = data['content'];
            if (data['points'] && data['to'] == '{$userinfo.id}') {
                var points = parseFloat($('#sy').html()) + parseFloat(data['points']);
                $('#sy').html(points);
            }
            $(".chatting").prepend('<div class="chatting-li qtr pink"><div class="portrait"><img src="/Public/main/img/system.jpg"/></div><div class="content"><small><span class="name">客服</span><time>' + time + '</time></small><p>' + content + '</p></div></div>');
            if(data.content.indexOf('已封盘')!=-1){
                return;
            }
            if(data.content.indexOf('距离封盘')!=-1){
                sptime=10;
                $('#zy_loead_top',window.parent.document).show()
                clearInterval(fpTime);
                fpTime=setInterval(()=>{
                    sptime--;
                    if(sptime<=0){
                        $('#zy_loead_top',window.parent.document).hide();
                        clearInterval(fpTime);
                        return;
                    }
                    $('#zy_loead_top',window.parent.document).html(sptime)
                },1000)
            }
        });
    });
</script>
<!--推送-->


<script src="/Template/Home/Run/js/zhicwl-z.js"></script>

</body>
</html>
